package operation;


import book.Book;
import book.BookList;

import java.util.Scanner;

public class Add implements IOperation {
    public void work(BookList bookList){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要添加的书籍:");
        String name = scanner.nextLine();
        System.out.println("请输入你要添加的书籍的作者:");
        String author = scanner.nextLine();
        System.out.println("请输入你要添加的书籍的类型:");
        String type = scanner.nextLine();
        System.out.println("请输入你要添加的书籍的价格:");
        int price = scanner.nextInt();

        Book book = new Book(name,author,price,type);

        int cur = bookList.getUsedSize();
        bookList.setBookList(cur,book);

        bookList.setUsedSize(cur+1);//成功放入一本书
        System.out.println("新增图书成功!");
    }
}
